import React, { memo, useState } from "react";
import { PaginationWrap } from "./style";
import { Pagination } from "antd";

export default memo(function PageD(props) {
  const [pageNum, setPageNum] = useState(1);

  const itemRender = (current, type, originalElement) => {
    if (type == "prev") {
      return <a>上一页</a>;
    }
    if (type == "next") {
      return <a>下一页</a>;
    }
    return originalElement;
  };

  const changePage = (page, pageSize) => {
    setPageNum(page);
    props.getPage(page);
  };

  return (
    <PaginationWrap>
      <Pagination
        hideOnSinglePage={true}
        current={props.page}
        onChange={changePage}
        defaultCurrent={props.page}
        pageSize={props.size}
        total={props.total}
        showSizeChanger={false}
        itemRender={itemRender}
      />
    </PaginationWrap>
  );
});
